57a9ff3632ccd26f32f039584bde838c26b04c95,fili-core/src/main/java/com/yahoo/bard/webservice/data/config/metric/makers/AggregationAverageMaker.java,AggregationAverageMaker,buildInnerQuery,#MetricField#TemplateDruidQuery#,115

Before Change


    private TemplateDruidQuery buildInnerQuery(MetricField sourceMetric, TemplateDruidQuery innerDependentQuery) {

        Set<Aggregation> newInnerAggregations = convertSketchesToSketchMerges(innerDependentQuery.getAggregations());
        Set<PostAggregation> newInnerPostAggregations = new LinkedHashSet<>();

        // If the sourceMetric is a Post Aggregator, we need to preserve it in the inner query
        if (sourceMetric instanceof PostAggregation) {
            newInnerPostAggregations.add((PostAggregation) sourceMetric);
        }

        // Build the inner query with the new aggregations and with the count

After Change


        Set<Aggregation> newInnerAggregations = convertSketchesToSketchMerges(innerDependentQuery.getAggregations());

        Set<PostAggregation> newInnerPostAggregations = !(sourceMetric instanceof PostAggregation) ?
                Collections.emptySet() : ImmutableSet.of((PostAggregation) sourceMetric);

        // Build the inner query with the new aggregations and with the count
        return innerDependentQuery.withAggregations(newInnerAggregations)
                .withPostAggregations(newInnerPostAggregations)
                .merge(buildTimeGrainCounterQuery());
    }